<template>
    <el-dialog v-model="dialogFormVisible" :title="title" width="800px" destroy-on-close center>
        <el-container>
            <el-main>
                <div class="content" v-html="valueHtml"></div>
            </el-main>
        </el-container>
    </el-dialog>
</template>

<script setup lang="ts">
import { ref, onBeforeUnmount } from 'vue'
import { getCompanyIntroduce } from '@/api/setting/index.ts'
import { bus } from "@/utils/mitt.js"
import { ElMessage } from "element-plus"
const title = ref('')
const dialogFormVisible = ref(false)
const valueHtml = ref()
bus.on("introduce", async (id: any) => {
    if (id == 1) {
        valueHtml.value = ''
        title.value = '编辑公司介绍'
        const res = await getCompanyIntroduce('公司介绍')
        if (res.status == 0) {
            valueHtml.value = res.data
        } else {
            ElMessage.error('获取失败')
        }
    }
    if (id == 2) {
        valueHtml.value = ''
        title.value = '编辑公司架构'
        const res = await getCompanyIntroduce('公司架构')
        if (res.status == 0) {
            valueHtml.value = res.data
        } else {
            ElMessage.error('获取失败')
        }
    }
    if (id == 3) {
        valueHtml.value = ''
        title.value = '编辑公司战略'
        const res = await getCompanyIntroduce('公司战略')
        if (res.status == 0) {
            valueHtml.value = res.data
        } else {
            ElMessage.error('获取失败')
        }
    }
    if (id == 4) {
        valueHtml.value = ''
        title.value = '编辑公司高层'
        const res = await getCompanyIntroduce('公司高层')
        if (res.status == 0) {
            valueHtml.value = res.data
        } else {
            ElMessage.error('获取失败')
        }
    }
})
const open = () => {
    dialogFormVisible.value = true
}
defineExpose({
    open
})
// 取消订阅/监听
onBeforeUnmount(() => {
    bus.all.clear()
})
</script>

<style scoped></style>
